export default {
  name: 'graphStore',
  state: {
    graph: null,
    historyCanRedo: false, // 是否有下一步
    historyCanUndo: false, // 是否有上一步
    selected: null // 选中的节点/边
  },
  mutations: {
    SET_HISTORY_CAN_REDO (state, value) {
      state.historyCanRedo = value
    },
    SET_HISTORY_CAN_UNDO (state, value) {
      state.historyCanUndo = value
    },
    SET_SELECTED (state, value) {
      state.selected = value
    },
    SET_SELECTED_PROP (state, prop) {
      state.selected.setProp(prop)
    },
    SET_SELECTED_DATA (state, data) {
      state.selected.setData({ ...data, timestamp: Date.now() }, { overwrite: true })
    },
    SET_SELECTED_ATTR (state, attr) {
      state.selected.setAttrs(attr.key, attr.value)
    },
    REMOVE_SELECTED (state, value) {
      state.selected = null
    }
  },
  actions: {
  }
}
